package cn.tedu.charging.order.controller;

import cn.tedu.chaging.common.web.JsonResult;
import cn.tedu.charging.order.pojo.param.OrderAddParam;
import cn.tedu.charging.order.service.OrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RequestMapping("/order")
@RestController
@Api(tags="订单相关接口")
public class OrderController {
    @Autowired
    private OrderService orderService;
    @ApiOperation("创建订单")
    @PostMapping("create")
    public JsonResult createOrder(@RequestBody @Validated OrderAddParam orderAddParam) {
        log.debug("创建订单的入参-{}",orderAddParam);
        //创建类型的接口是否返回结果，要根据业务进行。
        log.debug("进入service的入参-{}",orderAddParam);
        String orderNo =orderService.createOrder(orderAddParam);
        log.debug("service的入参-{},出参-{}",orderAddParam,orderNo);
//        JsonResult jsonResult =new JsonResult();
//        jsonResult.setCode(2000);
//        jsonResult.setMsg("创建订单成功");
//        jsonResult.setData(orderNo);
        log.debug("创建订单入参-{}",orderAddParam);
        return  JsonResult.ok(orderNo,"创建订单成功");
        //创建订单的接口出参应该是什么?

    }

}
